cmake_minimum_required(VERSION 3.16)
project(ObfuscatorPro VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# Find required Qt6 components
set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt@6/lib/cmake")
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Sql Concurrent)

# Include directories
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/include/core
    ${CMAKE_CURRENT_SOURCE_DIR}/include/ui
    ${CMAKE_CURRENT_SOURCE_DIR}/include/database
    ${CMAKE_CURRENT_SOURCE_DIR}/include/utils
)

# Add subdirectories
add_subdirectory(src)

# Create the main GUI executable
add_executable(ObfuscatorPro
    src/main.cpp
    resources/resources.qrc
)

# Link libraries
target_link_libraries(ObfuscatorPro
    Qt6::Core
    Qt6::Widgets
    Qt6::Sql
    Qt6::Concurrent
    ObfuscatorUI
    ObfuscatorDB
    ObfuscatorUtils
)

# Set properties
set_target_properties(ObfuscatorPro PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist
    MACOSX_BUNDLE_ICON_FILE AppIcon
)

# Copy icon to bundle
set(APP_ICON_MACOS "${CMAKE_CURRENT_SOURCE_DIR}/resources/AppIcon.icns")
set_source_files_properties(${APP_ICON_MACOS} PROPERTIES
    MACOSX_PACKAGE_LOCATION "Resources"
)
target_sources(ObfuscatorPro PRIVATE ${APP_ICON_MACOS})

# Install rules
install(TARGETS ObfuscatorPro
    BUNDLE DESTINATION .
    RUNTIME DESTINATION bin
)

# Install headers
install(DIRECTORY include/ DESTINATION include)